
import 'dart:convert';
import 'dart:ffi';
import 'dart:ui';

import 'package:crypto/crypto.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

import '../models/setting_model_entity.dart';
import '../models/user_info_model_entity.dart';

enum DATE_TRAVEL_STATE {
  NORMAL,
  PAY,
  SUCCESS
}

enum PAY_TYPE {
  ALI,
  WECHAT,
}

TextStyle NaviTitleStyle = new TextStyle(color: Colors.black, fontWeight: FontWeight.w700, fontSize: 17.sp);

String PRIVACY_ARGEEMENT = "https://iby.jiliol.cn/agreement/privacy-agreement.html";
String USER_AGREEMENT = "https://iby.jiliol.cn/agreement/user-agreement.html";

int RESPONSE_SUCCESS = 200;
int MAX_PHONE_LEHGTH = 11;
int MAX_CODE_LEHGTH = 5;

int IN_WEB_JUMP = 15;
int OUT_WEB_JUMP = 5;

int ENTER_MAIN = 0;
int ENTER_WEB = 1;

int SHOW_STAR = 1;

class Config {
  static UserInfoModelData userInfo = nullptr as UserInfoModelData;
  static SettingModelData settingInfo = nullptr as SettingModelData;
  static String massageUrl = "";

  static double lat = 0.0;
  static double lon = 0.0;

  static String cryptoClock() {
    var current = DateTime.now();
    if (current.hour < 10) {
      return md5.convert(utf8.encode("byamv0" + current.hour.toString())).toString();
    }

    return md5.convert(utf8.encode("byamv" + current.hour.toString())).toString();
  }

  static String convertToJsonStringQuotes({required String raw}) {
    /// remove space
    String jsonString = raw.replaceAll(" ", "");

    /// add quotes to json string
    jsonString = jsonString.replaceAll('{', '{"');
    jsonString = jsonString.replaceAll(':', '": "');
    jsonString = jsonString.replaceAll('https": "//', 'https://');
    jsonString = jsonString.replaceAll('http": "//', 'http://');
    jsonString = jsonString.replaceAll(',', '", "');
    jsonString = jsonString.replaceAll('}', '"}');

    /// remove quotes on object json string
    jsonString = jsonString.replaceAll('"{"', '{"');
    jsonString = jsonString.replaceAll('"}"', '"}');

    /// remove quotes on array json string
    jsonString = jsonString.replaceAll('"[{', '[{');
    jsonString = jsonString.replaceAll('}]"', '}]');

    return jsonString;
  }

  static bool isNull(value) {
    if (value == null)
      return true;

    if (value == "")
      return true;

    return false;
  }
}